import { defineStore } from 'pinia'

import { getorderListApi, postUpdateApi } from '@/api/orderList'

export const useorderList = defineStore('orderList', {
    state: () => {
        return {
            orderlist: [],
            total: 0,
            //分页
            page: 1,
            pageSize: 3
        }
    },
    getters: {

    },
    actions: {
        async getorderList() {
            const { data, total } = await getorderListApi({
                page: this.page - 1,
                pageSize: this.pageSize
            })
            this.orderlist = data
            this.total = total
        },
        async postpedestalfrom(from: object) {
            await postUpdateApi(from)
        },
        async getorderListExport() {
            const { data } = await getorderListApi({
                page: this.page - 1,
                pageSize: 100
            })
            return data
        },
    }
})